package com.ruoyi.im.mongo.dao.impl;

import com.mongodb.client.result.UpdateResult;
import com.ruoyi.im.mongo.dao.ImMongoMessageDao;
import com.ruoyi.im.mongo.domain.po.ImMongoMessagePO;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ImMongoMessageDaoImpl implements ImMongoMessageDao {
    @Resource
    private MongoTemplate mongoTemplate;
    @Override
    public ImMongoMessagePO saveMessage(ImMongoMessagePO message) {
        return mongoTemplate.save(message);
    }

    @Override
    public UpdateResult updateMessageState(ObjectId fromUserId, Integer state) {
        return null;
    }

    @Override
    public ImMongoMessagePO getById(ObjectId id) {
        Query query = Query.query(Criteria.where("id").is(id));
        return mongoTemplate.findOne(query, ImMongoMessagePO.class);
    }

    @Override
    public List<ImMongoMessagePO> getByGtNum(String roomId, String num) {
        return null;
    }

    @Override
    public List<ImMongoMessagePO> getByRoomId(String roomId) {
        return null;
    }

    @Override
    public ImMongoMessagePO maxNumByChatListId(ObjectId chatListId) {
        return null;
    }
}
